using System;
using System.Collections.Generic;
using System.Text;

namespace WMOSSExperts.Diagnostics
{
    public class Logger : IDisposable
    {
        String _entryPoint;
        System.Diagnostics.Stopwatch _watcher;

        public Logger(String entryPoint)
        {
            _watcher = new System.Diagnostics.Stopwatch();
            _watcher.Start();
            _entryPoint = entryPoint;
            TraceProvider.WriteTrace(TraceProvider.TraceSeverity.Verbose, LogCategory.WMOSSExpertsCore, _entryPoint + " => Start");
        }

        public void WriteTrace(TraceProvider.TraceSeverity severity, LogCategory category, String message)
        {
            TraceProvider.WriteTrace(severity, category, message);
        }


        #region IDisposable Members

        void IDisposable.Dispose()
        {
            _watcher.Stop();
            TraceProvider.WriteTrace(TraceProvider.TraceSeverity.Verbose, LogCategory.WMOSSExpertsCore, _entryPoint + " => Stop : Duration = " + _watcher.ElapsedMilliseconds.ToString() + " ms");
        }

        #endregion
    }
}
